#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>

#include <signal.h>
#include <sys/time.h>
#include <sys/wait.h>

#include "AsanDebug.h"

#undef TAG
#define TAG "AsanDebug"
//#ifdef __ANDROID__
#if 0
#include <android/log.h>
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
#else
#define LOGI(str, ...) do{printf("AsanDebug ");printf(str,##__VA_ARGS__);printf("\n");}while(0)
#define LOGD(str, ...) do{printf("AsanDebug ");printf(str,##__VA_ARGS__);printf("\n");}while(0)
#define LOGW(str, ...) do{printf("AsanDebug ");printf(str,##__VA_ARGS__);printf("\n");}while(0)
#define LOGE(str, ...) do{printf("AsanDebug ");printf(str,##__VA_ARGS__);printf("\n");}while(0)
#endif


int AsanDebug::asan_debug_foo(const int option) {
	int a = 0;
	int b = 0;
	int c = 0;
	char* p = NULL;
	LOGD("asan_debug_foo() enter");

	p = (char*)&b;
	unsigned long j = (sizeof(b) + sizeof(b) / 2);
	printf("j=%lu\n", j);
	*(p -2) = 0xcc;
	for (unsigned long i = 0; i < j; i ++ ) {
	   *p = 0xff;
	    p ++ ;
	}
	printf("a=0x%x\n", a);
	printf("b=0x%x\n", b);
	printf("c=0x%x\n", c);
	LOGD("asan_debug_foo() exit.");
	return option + 1;
}

int AsanDebug::asan_debug_foo2(const int option) {
	LOGD("asan_debug_Foo2() enter..");
	char* p = (char*)malloc(40); 
	for(int x = 0; x < 50; x ++) {p[x] = 'c';}
	return option + 2;
}